Skip to main content

All Questions

6votes
4answers
3kviews

How to print multi-line variables in side-by-side columns in sh?

This question is based on a similar question on Ask Ubuntu, but instead of bash, I would like to have similar output in sh. No issue in bash; it works as expected. wolf@linux:~$ echo $SHELL /usr/bin/...
Wolf's user avatar
  • 1,731
1vote
1answer
883views

How to solve the alignment problem of the columns in a text file after copy and paste?

I copied column 7,8 and 9 from file 1 into columns 7,8 and 9 in file 2 producing a new file 3. the produced file (file 3) is not aligned as the original files, How can I edit it to preserve the ...
Mohamed Abdelaal's user avatar
1vote
2answers
132views

How to add a column with a number or string that changes every time it finds a number on other column?

I have a file with different columns (three in this simplified example). The rows contain data of different replicates (Replicate_A, Replicate_B, Replicate_C). However, there is not the same amount of ...
Andrea Cabrera's user avatar
0votes
2answers
503views

Remove and replace column

I have a file which looks like this: 1 1 2 5.24 3 12.46 4 21.56 and so on. I need to change it to: 1 1 3 5.24 5 12.46 7 21.56 on a quick way. So the first column has to have odd values 2i+1 for i ...
Giacomo's user avatar
0votes
3answers
1kviews

How to add a column if line contains string?

If I have a tab-delimited file containing the following lines: Sample1-Baboon 1 2 3 4 Sample2-Human 1 2 3 4 Sample3-Human 1 2 3 4 Sample4-Baboon 1 2 3 4 How can I add a new column ...
Carmen Sandoval's user avatar
7votes
5answers
1kviews

A shell tool to “tablify” input data containing ANSI escape codes

I have input containing ANSI color codes that I'd like to tablify. I want the output to remain colored, so the tablified output should maintain the ANSI color codes. Hence, naively stripping them away ...
Jimmy Dean's user avatar
2votes
1answer
7kviews

shell script to print rows if there is a value in column 2

1 2 3 4 3 1 4 2 1 4 3 2 4 2 1 3 How can I print all rows, on which there is a 2 in the second column.
Kevin Parker's user avatar
7votes
1answer
7kviews

intersection of two files according to the first column

I have two files in file A, there are sequence_numbers in the other file B, there are many columns, and the first column is sequnce numbers, I want to get a files with all the lines in the B with the ...
wenzi's user avatar
6votes
1answer
4kviews

Linux sort second last column

I would like know how to sort the second last column ? It has the word "days=" in front of the number. I'm able to get the column with awk '{print $(NF-1)}', but sorting is wrong. 457000 (...
user11496's user avatar

close